home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Fades ƒ / BoxIn fade.c next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  2.6 KB  |  78 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        BoxIn fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define CorrectTime 3
  34.  
  35. pascal short BoxInFade(Rect boundsRect, Pattern *thePattern);
  36.  
  37. /* Basically, there are four bars -- one starts at the top and moves down;
  38.    one starts at the bottom and moves up; one starts at the left and moves
  39.    right; one starts at the right and moves left.  There's a lot of overlap
  40.    of bitcopying, but it's masked by the timing correction */
  41.    
  42. pascal short BoxInFade(Rect boundsRect, Pattern *thePattern)
  43. {
  44.     Rect        vsource1,vsource2, hsource1, hsource2;
  45.     int            vbar,hbar;
  46.     int            HBarGap,VBarGap;
  47.     
  48.     VBarGap=theWindowWidth/50;
  49.     HBarGap=theWindowHeight/50;
  50.     vbar=boundsRect.left;
  51.     hbar=boundsRect.top;
  52.     vsource1.top=vsource2.top=boundsRect.top;
  53.     vsource1.bottom=vsource2.bottom=boundsRect.bottom;
  54.     hsource1.left=hsource2.left=boundsRect.left;
  55.     hsource1.right=hsource2.right=boundsRect.right;
  56.     while (vbar<boundsRect.left+theWindowWidth/2+VBarGap)
  57.     {
  58.         StartTiming();
  59.         vsource1.left=vbar;
  60.         vsource1.right=vsource1.left+VBarGap;
  61.         vsource2.right=2*boundsRect.left+theWindowWidth-vbar;
  62.         vsource2.left=vsource2.right-VBarGap;
  63.         hsource1.top=hbar;
  64.         hsource1.bottom=hsource1.top+HBarGap;
  65.         hsource2.bottom=2*boundsRect.top+theWindowHeight-hbar;
  66.         hsource2.top=hsource2.bottom-HBarGap;
  67.         FillRect(&vsource1, *thePattern);
  68.         FillRect(&hsource1, *thePattern);
  69.         FillRect(&vsource2, *thePattern);
  70.         FillRect(&hsource2, *thePattern);
  71.         vbar+=VBarGap;
  72.         hbar+=HBarGap;
  73.         TimeCorrection(CorrectTime);
  74.     }
  75.     
  76.     return 0;
  77. }
  78.